Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popper.js

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popper.js

A kickass library to manage your poppers

  • 1.16.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4M
decreased by-26.68%
Maintainers
1
Weekly downloads
 
Created

What is popper.js?

The popper.js npm package is a library used for managing poppers in web applications. Poppers are elements on the screen that 'pop out' from the flow of the document and float near a target element. The library is commonly used for tooltips, popovers, dropdowns, and similar components that require positioning near a reference element.

What are popper.js's main functionalities?

Positioning tooltips

This code sample demonstrates how to create a popper instance to position a tooltip above a button. The 'createPopper' function from popper.js is used to bind the tooltip to the button with a placement option set to 'top'.

import { createPopper } from '@popperjs/core';

const tooltip = document.querySelector('#tooltip');
const button = document.querySelector('#button');

const popperInstance = createPopper(button, tooltip, {
  placement: 'top',
});

Creating dropdowns

This code sample shows how to use popper.js to create a dropdown menu that appears below the start of a reference element. The 'createPopper' function is used to attach the dropdown to the reference element.

import { createPopper } from '@popperjs/core';

const dropdown = document.querySelector('#dropdown');
const referenceElement = document.querySelector('#referenceElement');

const popperInstance = createPopper(referenceElement, dropdown, {
  placement: 'bottom-start',
});

Modifying popper behavior with modifiers

This example illustrates how to use modifiers to alter the behavior of a popper. Here, an 'offset' modifier is added to provide a gap between the popper and the reference element.

import { createPopper } from '@popperjs/core';

const popper = document.querySelector('#popper');
const referenceElement = document.querySelector('#referenceElement');

const popperInstance = createPopper(referenceElement, popper, {
  modifiers: [
    {
      name: 'offset',
      options: {
        offset: [0, 8],
      },
    },
  ],
});

Other packages similar to popper.js

Keywords

FAQs

Package last updated on 22 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc